package nix.mall.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import nix.mall.common.pojo.EasyUIDataGridResult;
import nix.mall.common.pojo.NixMallResult;
import nix.mall.pojo.Item;
import nix.mall.service.ItemService;

/**
 * 商品管理Controller
 */
@Controller
public class ItemController {

	
	@Autowired
	private ItemService itemService;
	
	@RequestMapping("item/{itemId}")
	@ResponseBody
	public Item getItemById(@PathVariable Long itemId) {
		Item item = itemService.getItemById(itemId);
		return item;
	}
	
	@RequestMapping("item/list")
	@ResponseBody
	public EasyUIDataGridResult getItemList(Integer page, Integer rows) {
		EasyUIDataGridResult result = itemService.getItemList(page, rows);
		return result;
	}
	
	@RequestMapping(value = "item/save", method = RequestMethod.POST)
	@ResponseBody
	public NixMallResult addItem(Item item, String desc) {
		NixMallResult result = itemService.addItem(item, desc);
		return result;
	}
}
